<?php

namespace Builder;

/**
 * 构建器
 */
class ZBuilder
{
    /**
     * @var array 构建器数组
     */
    protected static $builder = [];

    /**
     * 初始化
     */
    public function __construct(){}

    /**
     * 创建各种builder的入口
     * @param string $type 构建器名称，'Form', 'Table', 'View' 或其他自定义构建器
     * @return mixed
     * @throws \Exception|object
     */
    public static function make($type = '')
    {
        if ($type == '') {
            throw new \Exception('未指定构建器名称', 8001);
        } else {
            $type = strtolower($type);
        }

        // 构造器类路径
        $class = '\\builder\\'. $type .'\\Builder';
        $d = class_exists($class);
        var_dump($d);
        var_dump($class);die;
        if (!class_exists($class)) {
            throw new \Exception($type . '构建器不存在', 8002);
        }

        return new $class;
    }
}
